# 抽取配置文件
from redis import StrictRedis
import logging

class Config(object):
    '''添加配置信息类'''
    DEBUG = True
    SECRET_KEY = "EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQUs8yCM6xX9Yjq52v54g+HVoknA"
    # 配置数据库接口
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN =True

    # 创建redis数据库配置接口
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = "6379"
    # 利用 flask-session扩展，将 session 数据保存到 Redis 中
    # 使用redis储存session
    SESSION_TYPE = 'redis'
    SESSION_USE_SIGNER = True
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    PERMANENT_SESSION_LIFETIME = 86400 * 2 # 设置session的有效时间
    LOG_LEVEL = logging.DEBUG


class DevelopmentConfig(Config):
    '''开发阶段所需要的配置项'''
    DEBUG = True
    LOG_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    '''生产阶段所需要的配置项'''
    DEBUG = False
    LOG_LEVEL = logging.ERROR


Config = {"development" : DevelopmentConfig,
               "product" : ProductionConfig}